package com.arcgis.app.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.arcgis.app.R;
import com.google.android.material.button.MaterialButton;

public class CommonSectionHeader extends LinearLayout {
//    private MaterialButton btn_actionBtn;

    private View.OnClickListener rightActionClickListener;
    private TextView tv_left_title;
    private TextView tv_center_title;

    public void setLeftTitle(String title){
        tv_left_title.setText(title);
    }

    public void setMidTitle(String title){
        tv_center_title.setText(title);
    }

    public CommonSectionHeader(Context context) {
        super(context);
    }

    public CommonSectionHeader(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        View inflate = inflate(getContext(), R.layout.common_section_header, this);

        tv_left_title = inflate.findViewById(R.id.tv_common_section_header_left_title);

         tv_center_title = inflate.findViewById(R.id.tv_common_section_header_middle_title);

//        btn_actionBtn = inflate.findViewById(R.id.btn_common_section_header_right);

        TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.CommonHeaderView);

        if(attributes != null){

            String title = attributes.getString(R.styleable.CommonSectionHeaderView_section_title);

            String middle_title = attributes.getString(R.styleable.CommonSectionHeaderView_section_middle_title);

            String action_right_title = attributes.getString(R.styleable.CommonSectionHeaderView_action_right_title);


            if(title != null){

                tv_left_title.setText(title);
            }

            if(middle_title != null){

                tv_center_title.setText(middle_title);
            }

//            if(action_right_title != null){
//
//                btn_actionBtn.setClickable(true);
//                btn_actionBtn.setText(action_right_title);
//
//            }
//            else{
//                btn_actionBtn.setClickable(false);
//            }

        }
    }

    public CommonSectionHeader(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }



    public void setRightActionClickListener(OnClickListener rightActionClickListener) {
        this.rightActionClickListener = rightActionClickListener;
//        btn_actionBtn.setOnClickListener(this.rightActionClickListener);

    }

}
